function res = leastSquares(x, y)
sumX = sum(x);
sumY = sum(y);
sumXX = sum(x.*x);
xy = x.*y;
sumXY = sum((xy));
n = length(x);
denom = n * sumXX - square(sumX);
a = (n * sumXY - sumX * sumY) / denom;
b = (sumXX * sumY - sumX * sumXY)/denom;
c = (sumY- a* sumX - b * n)/n;
res = a * (n+1)*(n+1) + b*(n+1) + c;
end
